<?php

namespace common\jobs;

use Yii;
use yii\helpers\ArrayHelper;
use JPush\Client;
use yii\console\Exception;

/**
 * 短信任务
 * Class SmsJob.
 */
class SmsJob extends \yii\base\BaseObject implements \yii\queue\JobInterface {

    public $mobile = null;
    public $template = null;
    public $content = null;
    public $params = [];
    public $options = [];

    /**
     * @inheritdoc
     */
    public function execute($queue) {
        if ($this->mobile == null || (!$this->template && !$this->content)) {
            return false;
        }

        if ($this->template != null) {
            //阿里大鱼短信
            $sendStatus = Yii::$app->dysms->sendSms($this->mobile, $this->template, $this->params, $this->options);
            if ($sendStatus !== true) {
                Yii::error('[Sms send faild]:' . \yii\helpers\VarDumper::export($sendStatus));
                return false;
            }
        } elseif ($this->content != null) {
            //普通短信
        }

        return true;
    }

}
